package string;

public class 动态口令 {
    //字符串切片
    class Solution {
        public String dynamicPassword(String password, int target) {
            return password.substring(target,password.length()) + password.substring(0,target);
        }
    }
    //列表遍历拼接
    class Solution2 {
        public String dynamicPassword(String password, int target) {
            StringBuilder res = new StringBuilder();
            for(int i = target; i < password.length(); i++)
                res.append(password.charAt(i));
            for(int i = 0; i < target; i++)
                res.append(password.charAt(i));
            return res.toString();
        }
    }
    //字符串遍历拼接
    class Solution3 {
        public String dynamicPassword(String password, int target) {
            String res = "";
            for(int i = target; i < password.length(); i++)
                res += password.charAt(i);
            for(int i = 0; i < target; i++)
                res += password.charAt(i);
            return res;
        }
    }
}
